<template>
	<view class="container">
		<view class="topbox">
			<image class="topbg" src="/static/img/wallet/bg.png" mode=""></image>
			<view class="topcon">
				<view class="toptitle">
					金钱消费总额
				</view>
				<view class="qiannum">
					<text style="margin-right: 10rpx;">￥</text>{{ totalPrice.toFixed(2) }}
				</view>
				<view class="czbox">
					<view class="box_item">
						<view class="">
							贡献值消费总额
						</view>
						<view class="" style="font-size: 36rpx;font-weight: bold;">
							{{totalScoreB}}
						</view>
					</view>
					<view class="czline">
						
					</view>
					<view class="box_item">
						<view class="">
							惠值积分消费总额
						</view>
						<view class="" style="font-size: 36rpx;font-weight: bold;">
							{{totalScoreA}}
						</view>
					</view>
				</view>
			</view>
			
		</view>
		
		<view class="con">
			<view class="title">
				我的账单
			</view>
			<scroll-view scroll-y="true" class="scroll-view" @scrolltolower='scrolltolower'>
				<view>
					<view class="minxitem" v-for="(item,index) in mxlist" :key="index">
						<image v-if="item.method==0||item.method==1||item.method==2" class="qian_icon" src="/static/img/wallet/qian.png" mode=""></image>
						<image class="qian_icon" v-if="item.method==3" src="/static/img/tongz/zs.png" mode=""></image>
						<image class="qian_icon" v-if="item.method==4" src="/static/img/tongzhi/zs.png" mode=""></image>
						<view class="item_right">
							<view class="right_top">
								<text>{{item.pay_name}}</text>
								<text v-if="item.type==1" style="color: #FA4600;font-size: 33rpx;">+{{item.price}}</text>
								<text v-if="item.type==0" style="font-size: 33rpx;">-{{item.price}}</text>
							</view>
							<view class="time">
								{{$u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM')}}
								<!-- {{item.time}} -->
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" line />
			</scroll-view>
			
		</view>
	</view>
</template>

<script>
	import { ourRecord } from '@/api/my.js'
	export default {
		data() {
			return {
				mxlist:[],
				userInfo: {},
				status:'loadmore',
				page:1,
				last_page:0,
				totalPrice:0,
				totalScoreB:0,
				totalScoreA:0
			}
		},
		methods: {
			clickto(url){
				uni.$u.route(url);
			},
			geTourRecord(){
				this.status='loading'
				ourRecord({ page: this.page }).then(res => {
					this.last_page=res.data.data.list.last_page
					this.mxlist = [...this.mxlist,...res.data.data.list.data]
					// console.log(res.data.data.totalPrice)
					this.totalPrice=res.data.data.totalPrice
					this.totalScoreB=res.data.data.totalScoreB
					this.totalScoreA=res.data.data.totalScoreA
					this.status='loadmore'
				})
			},
			// 滚动到底部
			scrolltolower(){
				// console.log('到底')
				this.page++
				// console.log(this.page,this.last_page)
				if(this.page<=this.last_page){
					this.geTourRecord()
				}else{
					this.status='nomore'
				}
			}
		},
		mounted() {
			this.geTourRecord()
		},
		onLoad(data) {
			this.userInfo = data
			this.userInfo=uni.getStorageSync('userinfo')
		}
	}
</script>

<style lang="less">
.container{
	padding: 40rpx 30rpx 20rpx;
	.topbox{
		width: 690rpx;
		height: 382rpx;
		position: relative;
		color: #fff;
		.topbg{
			position: absolute;
			top: 0;
			left: 0;
			width: 690rpx;
			height: 382rpx;
		}
		.topcon{
			height: 282rpx;
			position: absolute;
			top: 0;
		}
		.toptitle{
			font-size: 24rpx;
			padding-top: 57rpx;
			padding-left: 47rpx;
			margin-bottom:56rpx;
		}
		.qiannum{
			font-size: 50rpx;
			font-weight: bold;
			padding-left: 46rpx;
			padding-bottom: 60rpx;
		}
		.czbox{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32rpx;
			width: 688rpx;
			.czline{
				width: 1rpx;
				height: 29rpx;
				background: rgba(254, 253, 255, 1);
				opacity: 0.2;
				margin: 0 76rpx;
			}
			.czicon{
				width: 42rpx;
				height: 42rpx;
				margin-right: 22rpx;
			}
			.box_item{
				display: flex;
				align-items: center;
				flex-direction: column;
				font-size: 24rpx;
			}
		}
	}
}
.title{
	font-size: 34rpx;
	color: #3F3F3F;
	font-weight: bold;
	margin-top: 44rpx;
	line-height: 40rpx;
}
.minxitem{
	display: flex;
	align-items: center;
	padding: 35rpx 0;
	border-bottom: 1rpx solid #F5F4F4;
	.qian_icon{
		width: 76rpx;
		height: 76rpx;
	}
	.item_right{
		padding-right: 20rpx;
		padding-left: 16rpx;
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		
		.right_top{
			display: flex;
			justify-content: space-between;
			color: #333333;
			font-size: 26rpx;
			font-weight: bold;
			align-items: center;
		}
		.time{
			color: #A2A1A0;
			font-size: 24rpx;
		}
	}
}
.scroll-view{
	margin-top: 20rpx;
	height: calc(100vh - 40rpx - 44rpx - 382rpx - 40rpx - 20rpx - 44px - 20rpx);
	/* #ifdef MP */
	height: calc(100vh - 40rpx - 44rpx - 382rpx - 40rpx - 20rpx - 20rpx);
	/* #endif */
}
</style>
